﻿<?

	session_start();
	
	/*if(isset($_GET['keywords'])){
	
		$_SESSION['search_string'] = $_GET['keywords'];
		$_SESSION['advanced']=false;
		
	}else if(isset($_GET['advancedwords'])){
	
		$_SESSION['search_string'] = $_GET['advancedwords'];
		$_SESSION['advanced']=true;
	
	}*/


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Xpert search results</title>
<style>

	html{
	
		margin:0px;
		padding:0px;
		font-family:Verdana, Arial, Helvetica, sans-serif;
	
	}
	
	body{
	
		margin:0px;
		padding:0px;
	
	}
	
	.top_wrapper{

		width:100%; 
		background-color:#F9F9F9; 
		height:44px
	
	}
	
	.text_centre{
		
		width:950px; 
		margin:0 auto; 
		text-align:center;
	
	}
	
	.top_left{
	
		width:500px; 
		float:left; 
		position:relative; 
		text-align:left; 
		font-size:80%; 
		font-weight:bold; 
		color:#434343; 
		padding-top:12px;
	
	}
	
	.top_left span{
		
		border-left:1px solid #D6D6D6; 
		padding:0 10px
	
	}
	
	.top_left span a, .top_right span a{
	
		color:#434343;
		
	}
	
	.top_right{
	
		width:450px; 
		float:right; 
		position:relative; 
		height:100%; 
		text-align:left; 
		font-size:80%; 
		font-weight:bold; 
		color:#434343; 
		padding-top:12px;
	
	}
	
	.top_right span{
		
		border-left:1px solid #D6D6D6; 
		padding:0 10px;
		
	}
	
	.main_wrapper{
	
		float:left; 
		position:relative; 
		width:100%; 
		text-align:center;
	
	}
	
	.page_holder{
	
		width:900px; 
		text-align:left; 
		margin:0 auto; 
		height:100px;
	
	}
	
	.logo{
		
		float:left; 
		position:relative; 
		height:100px; 
		width:149px;
	
	}
	
	.contributors{
	
		float:left; 
		position:relative; 
		height:500px; 
		width:100%; 
		background-color:#FFFFFF;  
		margin-top:20px; 
		text-align:center
	
	}
	
	.contributors a{
	
		color:#7C7C7C; 
		text-decoration:none;
	
	}

	.index_holder{
	
		width:950px; 
		margin:0 auto; 
		text-align:center;
	
	}
	
	.index_left{
	
		width:500px; 
		float:left; 
		position:relative; 
		height:500px; 
		background-color:#FFFFFF; 
		text-align:center;
	
	}
	
	.index_left p{
	
		font-size:80%; 
		font-weight:bold; 
		margin-top:40px;
	
	}
	
	.index_left p a{
	
		color:#434343;
	
	}
	
	.tag_cloud{
	
		width:450px; 
		float:left; 
		position:relative; 
		height:500px; 
		text-align:left
	
	}
	
	.tag_cloud p{
	
		color:#9C8A5A; 
		font-weight:bold; 
		font-size:110%; 
		padding-top:38px;
	
	}
	
	.submit_centre{
	
		width:900px; 
		text-align:left; 
		margin:0 auto; 
		height:100px;
		
	}
	
	.top_search_box{
	
		float:left; 
		position:relative; 
		margin-left:20px;
		
	}
	
	.top_search_box p{
	
		font-size:75%; 
		font-weight:bold;
	
	}
	
	.top_search_box p a{
	
		color:#434343;
	
	}
	
	.results_holder{
	
		width:900px; 
		text-align:left; 
		margin:0 auto; 
		clear:left; 
		border-top:1px solid #D2c598; 
		color:#665723; 
		font-weight:bold; 
		height:20px; 
		padding-top:10px; 
		margin-bottom:25px;
	
	}
	
	.pages{
	
		float:right; 
		font-size:80%; 
		color:#333;	
		
	}
	
	.pages span, .pages span a{
	
		color:#665723;
	
	}
	
	.button_bar_index{
	
		float:left; 
		position:relative; 
		width:100%; 
		height:30px; 
		font-weight:bold; 
		background-color:#F5F5F5; 
		font-size:80%;
	
	}
	
	.license{
	
		float:left; 
		position:relative; 
		width:150px; 
		padding:5px; 
		color:#766B2B; 
		background-color:#DAD7D2; 
		text-align:center;  
		margin-right:5px; 
		cursor:hand; 
		cursor:pointer;
				
	}
	
	.related{
	
		float:left; 
		position:relative; 
		background-color:#A9A9A9; 
		width:150px; 
		padding:5px; 
		text-align:center; 
		margin-right:5px; 
		cursor:hand; 
		cursor:pointer;
	
	}
	
	.recommend{
	
		float:left; 
		position:relative; 
		background-color:#A9A9A9; 
		width:150px; 
		padding:5px; 
		text-align:center;  
		margin-right:5px; 
		cursor:hand; 
		cursor:pointer;
	
	}
	
	.tab_holder{
	
		background-color:#F5F5F5; 
		font-size:80%; 
		width:100%
		
	}
	
	.relation{
	
		border-top:1px solid #655723; 
		margin:10px; 
		padding:10px; 
		display:none;
	
	}
	
	.recommender{
	
		border-top:1px solid #655723; 
		margin:10px; 
		padding:10px; 
		display:none
	
	}

</style>
<script language="javascript" type="text/javascript" src="display_and_email.js">

	
</script>
</head>
<body>
	<div class="top_wrapper">
		<div class="text_centre">
			<div class="top_left">
				<span>  
					<a href="http://www.nottingham.ac.uk/xpert/">Back to main page</a>  
				</span>
			</div>
			<div class="top_right">
						<span>  <a href="feedsubmit.php">Submit a link</a>  </span><span>  <a href="rss.php">Subscribe to RSS</a>  </span><span><a href="about.php">About</a></span><span><a href="contributors.php">Contributors</a></span>
			</div>
		</div>
	</div>
	<div class="main_wrapper">
		<div style="width:900px; text-align:left; margin:0 auto; height:100px;">
			<div class="logo">
				<img src="http://www.nottingham.ac.uk/xpert/images/logoresults.gif" />
			</div>
			<div class="top_search_box">
				<form action="scoreresults.php" method="get" enctype="multipart/form-data">
					<input type="text" size="70" name="keywords" value='<? echo stripcslashes($_GET['keywords']); ?>' />
					<input type="image" src="http://www.nottingham.ac.uk/xpert/images/search.gif" style="position:relative; top:15px" />
				</form>
				<p>
					<a href="advancedsearch.php">Advanced search</a> | <a href="browse.php">Browse Resources</a>
				</p>	
			</div>
		</div>		
		<div class="results_holder">
			<div style="float:left">Search results</div>
			<div class="pages">
<?

	function is_not_to_be_found($var){
	
		if(strpos($var,"-")===0){
		
			return true;
		
		}else{
		
			return false;
		
		}
	
	}

	include "xpert_database.php";
	
	xpert_database_connect($xpert_site);
	
	xpert_database_select($xpert_site);
		
	$pattern ='/\-?"[\w\-\s\.%$£&\(\)]*"\.*\?*\s?|\-?[\w\-%$£&\(\)]*\?*\.*\s?/';
	
	$restricted_ids = array();
	
	if(isset($_GET['advancedwords'])){
	
		if($_GET['contributor']!="All"){
		
			$query = "select * from xpert_core_contributor where resource_contributor = \"" . mysql_real_escape_string($_GET['contributor']) . "\"";

			$site_contributors = xpert_database_multiple_select_query($query, $xpert_site);
			
			while($site_contributors_object = xpert_database_fetch_object_from_response($site_contributors)){	
			
				array_push($restricted_ids, $site_contributors_object->resource_id);
			
			}		
		
		}
	
		if($_GET['creator']!="All"){
		
			$query = "select * from xpert_core_creator where resource_creator = \"" . mysql_real_escape_string($_GET['creator']) . "\"";
		
			$site_authors = xpert_database_multiple_select_query($query, $xpert_site);
		
			while($site_authors_object = xpert_database_fetch_object_from_response($site_authors)){	
			
				array_push($restricted_ids, $site_authors_object->resource_id);
			
			}		
		
		}	
		
		if($_GET['format']!="All"){
		
			$query = "select * from xpert_core_format where resource_format = \"" . mysql_real_escape_string($_GET['format']) . "\"";
		
			$site_formats = xpert_database_multiple_select_query($query, $xpert_site);
		
			while($site_format_object = xpert_database_fetch_object_from_response($site_formats)){	
			
				array_push($restricted_ids, $site_format_object->resource_id);
			
			}		
		
		}
		
		if($_GET['publisher']!="All"){
		
			$query = "select * from xpert_core_publisher where resource_publisher = \"" . mysql_real_escape_string($_GET['publisher']) . "\"";
		
			$site_publishers = xpert_database_multiple_select_query($query, $xpert_site);
		
			while($site_publisher_object = xpert_database_fetch_object_from_response($site_publishers)){	
			
				array_push($restricted_ids, $site_publisher_object->resource_id);
			
			}		
		
		}
		
		if($_GET['rights']!="All"){
		
			$query = "select * from xpert_core_rights where resource_rights = \"" . mysql_real_escape_string($_GET['rights']) . "\"";
		
			$site_rights = xpert_database_multiple_select_query($query, $xpert_site);
		
			while($site_rights_object = xpert_database_fetch_object_from_response($site_rights)){	
			
				array_push($restricted_ids, $site_rights_object->resource_id);
			
			}		
		
		}	
		
		if($_GET['subject']!="All"){
		
			$query = "select * from xpert_core_subject where resource_rights = \"" . mysql_real_escape_string($_GET['subject']) . "\"";
		
			$site_subject = xpert_database_multiple_select_query($query, $xpert_site);
		
			while($site_subject_object = xpert_database_fetch_object_from_response($site_subject)){	
			
				array_push($restricted_ids, $site_subject_object->resource_id);
			
			}		
		
		}	
		
		if(count($restricted_ids)==0){
		
			$query = "select * from xpert_core_scratch ";
		
			$site_subject = xpert_database_multiple_select_query($query, $xpert_site);
		
			while($site_subject_object = xpert_database_fetch_object_from_response($site_subject)){	
			
				array_push($restricted_ids, $site_subject_object->resource_id);
			
			}
		
		}else{
		
						
		}
	
	}	
	
	if(!isset($_GET['keywords'])){
	
		$keywords = mysql_real_escape_string(stripcslashes(urldecode($_GET['advancedwords'])));
	
	}else{
	
		$keywords = mysql_real_escape_string(stripcslashes(urldecode($_GET['keywords'])));
	
	}

	preg_match_all($pattern, rtrim(stripcslashes($keywords)), $results);

	//
	//
	// TITLE
	//
	//
	
	$take_out_values = array_filter($results[0],"is_not_to_be_found");
	
	$query = "select * from xpert_core_scratch where ";

	$search_for_values = array_diff($results[0], $take_out_values);
	
	for($x=0;$x!=count($take_out_values);$x++){
	
		if(ltrim(rtrim($take_out_values[$x]))!=""){
	
			$query .= " resource_title NOT LIKE (\"% " . rtrim(substr($take_out_values[$x],1)) . " %\") ";
			
			if($x!=count($take_out_values)-1){
		
				$query .= " AND ";
		
			}
			
		}
	
	}
	
	if($query !=  "select * from xpert_core_scratch where "){
	
		$query .= " AND";
	
	}
	
	array_pop($search_for_values);
	
	for($x=0;$x!=count($search_for_values);$x++){
	
		if(ltrim(rtrim($search_for_values[$x]))!=""){
		
			$query .= " resource_title LIKE (\"%" . str_replace("\"","",rtrim($search_for_values[$x])) . "%\")";
				
			if($x!=count($search_for_values)-1){
			
				$query .= " OR ";
			
			}
				
		}
		
	}
		
	$results_score_array = array();
	$results_object_array = array();
		
	$site_questions = xpert_database_multiple_select_query($query, $xpert_site);
		
	while($site_questions_object = xpert_database_fetch_object_from_response($site_questions)){
	
		if(isset($_GET['advancedwords'])){
		
			if(in_array($site_questions_object->resource_id,$restricted_ids)){
			
				$results_score_array[$site_questions_object->resource_id] = 0;
				$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
				
				for($x=0;$x!=count($search_for_values);$x++){
				
					$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
					$results_score_array[$site_questions_object->resource_id] += ($score*5);
			
				}
			
			
			}
			
		
		}else{
		
			$results_score_array[$site_questions_object->resource_id] = 0;
			$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
				
			for($x=0;$x!=count($search_for_values);$x++){
				
				$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
				$results_score_array[$site_questions_object->resource_id] += ($score*5);
			
			}
			
		}
	
	
	}
		
	//
	//
	// DESCRIPTION
	//
	//
	
		
	$query = "select * from xpert_core_description where ";
	
	$search_for_values = array_diff($results[0], $take_out_values);
		
	for($x=0;$x!=count($take_out_values);$x++){
		
		if(ltrim(rtrim($take_out_values[$x]))!=""){
		
			$query .= " resource_description NOT LIKE (\"% " . rtrim(substr($take_out_values[$x],1)) . " %\") ";
				
			if($x!=count($take_out_values)-1){
			
				$query .= " AND ";
			
			}
				
		}
		
	}
		
	if($query !=  "select * from xpert_core_description where "){
		
		$query .= " AND";
		
	}
		
	array_pop($search_for_values);
		
	for($x=0;$x!=count($search_for_values);$x++){
		
		if(ltrim(rtrim($search_for_values[$x]))!=""){
		
			$query .= " resource_description LIKE (\"%" . str_replace("\"","",rtrim($search_for_values[$x])) . "%\")";
				
			if($x!=count($search_for_values)-1){
			
				$query .= " OR ";
			
			}
				
		}
		
	}
			
	$site_questions = xpert_database_multiple_select_query($query, $xpert_site);
			
		
	while($site_questions_object = xpert_database_fetch_object_from_response($site_questions)){
		
		if(isset($_GET['advancedwords'])){
		
			if(in_array($site_questions_object->resource_id,$restricted_ids)){
		
				if(!isset($results_score_array[$site_questions_object->resource_id])){
				
					$results_score_array[$site_questions_object->resource_id] = 0;
					$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
				
				}
				
				for($x=0;$x!=count($search_for_values);$x++){
				
					$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
					$results_score_array[$site_questions_object->resource_id] += $score*3;
			
				}
				
			}
			
		
		}else{
		
			if(!isset($results_score_array[$site_questions_object->resource_id])){
				
				$results_score_array[$site_questions_object->resource_id] = 0;
				$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
			
			}
				
			for($x=0;$x!=count($search_for_values);$x++){
				
				$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
				$results_score_array[$site_questions_object->resource_id] += $score*3;
			
			}
			
		}
	
	}
		
	///
	///
	/// AUTHOR
	///
	///
	///
		
	$query = "select * from xpert_core_creator where ";
	
	$search_for_values = array_diff($results[0], $take_out_values);
		
	for($x=0;$x!=count($take_out_values);$x++){
		
		if(ltrim(rtrim($take_out_values[$x]))!=""){
	
			$query .= " resource_creator NOT LIKE (\"%" . rtrim(substr($take_out_values[$x],1)) . "%\") ";
				
			if($x!=count($take_out_values)-1){
			
				$query .= " AND ";
			
			}
				
		}
		
	}
		
	if($query !=  "select * from xpert_core_creator where "){
		
		$query .= " AND";
		
	}
		
	array_pop($search_for_values);
		
	for($x=0;$x!=count($search_for_values);$x++){
		
		if(ltrim(rtrim($search_for_values[$x]))!=""){
		
			$query .= " resource_creator LIKE (\"%" . str_replace("\"","",rtrim($search_for_values[$x])) . "%\")";
				
			if($x!=count($search_for_values)-1){
			
				$query .= " OR ";

			
			}
				
		}
		
	}
		
		
	$site_questions = xpert_database_multiple_select_query($query, $xpert_site);
		
	while($site_questions_object = xpert_database_fetch_object_from_response($site_questions)){
		
		if(isset($_GET['advancedwords'])){
		
			if(in_array($site_questions_object->resource_id,$restricted_ids)){
		
				if(!isset($results_score_array[$site_questions_object->resource_id])){
				
					$results_score_array[$site_questions_object->resource_id] = 0;
					$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
				
				}
				
				for($x=0;$x!=count($search_for_values);$x++){
				
					$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
					$results_score_array[$site_questions_object->resource_id] += $score*3;
			
				}
				
			}
			
		
		}else{
		
			if(!isset($results_score_array[$site_questions_object->resource_id])){
				
				$results_score_array[$site_questions_object->resource_id] = 0;
				$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
			
			}
				
			for($x=0;$x!=count($search_for_values);$x++){
				
				$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
				$results_score_array[$site_questions_object->resource_id] += $score*3;
			
			}
			
		}
	
	}
	
	///
	///
	/// KEYWORDS
	///
	///
	///
		
	$query = "select * from xpert_core_subject where ";
	
	$search_for_values = array_diff($results[0], $take_out_values);
		
	for($x=0;$x!=count($take_out_values);$x++){
		
		if(ltrim(rtrim($take_out_values[$x]))!=""){
		
			$query .= " resource_subject NOT LIKE (\"%" . rtrim(substr($take_out_values[$x],1)) . "%\") ";
				
			if($x!=count($take_out_values)-1){
			
				$query .= " AND ";
		
			}
				
		}
		
	}
		
	if($query !=  "select * from xpert_core_subject where "){
		
		$query .= " AND";
		
	}
		
	array_pop($search_for_values);
		
	for($x=0;$x!=count($search_for_values);$x++){
		
		if(ltrim(rtrim($search_for_values[$x]))!=""){
		
			$query .= " resource_subject LIKE (\"%" . str_replace("\"","",rtrim($search_for_values[$x])) . "%\")";
				
			if($x!=count($search_for_values)-1){
			
				$query .= " OR ";
			
			}
				
		}
		
	}
		
	$site_questions = xpert_database_multiple_select_query($query, $xpert_site);
	
	while($site_questions_object = xpert_database_fetch_object_from_response($site_questions)){
		
		if(isset($_GET['advancedwords'])){
		
			if(in_array($site_questions_object->resource_id,$restricted_ids)){
		
				if(!isset($results_score_array[$site_questions_object->resource_id])){
				
					$results_score_array[$site_questions_object->resource_id] = 0;
					$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
				
				}
				
				for($x=0;$x!=count($search_for_values);$x++){
				
					$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
					$results_score_array[$site_questions_object->resource_id] += $score*3;
			
				}
				
			}
			
		
		}else{
		
			if(!isset($results_score_array[$site_questions_object->resource_id])){
				
				$results_score_array[$site_questions_object->resource_id] = 0;
				$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
			
			}
				
			for($x=0;$x!=count($search_for_values);$x++){
				
				$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
				$results_score_array[$site_questions_object->resource_id] += $score*3;
			
			}
			
		}	
	
	}
		
	///
	///
	/// SOURCE
	///
	///
		
	$query = "select * from xpert_core_source where ";
	
	$search_for_values = array_diff($results[0], $take_out_values);
		
	for($x=0;$x!=count($take_out_values);$x++){
		
		if(ltrim(rtrim($take_out_values[$x]))!=""){
		
			$query .= " resource_source NOT LIKE (\"%" . rtrim(substr($take_out_values[$x],1)) . "%\") ";
				
			if($x!=count($take_out_values)-1){

			
				$query .= " AND ";
			
			}
				
		}
		
	}
		
	if($query !=  "select * from xpert_core_source where "){
		
		$query .= " AND";
		
	}
		
	array_pop($search_for_values);
		
	for($x=0;$x!=count($search_for_values);$x++){
		
		if(ltrim(rtrim($search_for_values[$x]))!=""){
		
			$query .= " resource_source LIKE (\"%" . str_replace("\"","",rtrim($search_for_values[$x])) . "%\")";
				
			if($x!=count($search_for_values)-1){
			
				$query .= " OR ";
			
			}
				
		}
		
	}
		
	$site_questions = xpert_database_multiple_select_query($query, $xpert_site);
	
	while($site_questions_object = xpert_database_fetch_object_from_response($site_questions)){
		
		if(isset($_GET['advancedwords'])){
		
			if(in_array($site_questions_object->resource_id,$restricted_ids)){
		
				if(!isset($results_score_array[$site_questions_object->resource_id])){
				
					$results_score_array[$site_questions_object->resource_id] = 0;
					$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
				
				}
				
				for($x=0;$x!=count($search_for_values);$x++){
				
					$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
					$results_score_array[$site_questions_object->resource_id] += $score*3;
			
				}
				
			}
			
		
		}else{
		
			if(!isset($results_score_array[$site_questions_object->resource_id])){
				
				$results_score_array[$site_questions_object->resource_id] = 0;
				$results_object_array[$site_questions_object->resource_id] = $site_questions_object;
			
			}
				
			for($x=0;$x!=count($search_for_values);$x++){
				
				$score = count(explode($site_questions_object->resource_title,$search_for_values[$x]));
		
				$results_score_array[$site_questions_object->resource_id] += $score*3;
			
			}
			
		}
	
	}
			
	/////////////////////////
		
	$z = 0;
	
	xpert_database_insert_query("INSERT INTO xpert_search_stats(search_terms, search_results, search_time)VALUES('" . mysql_real_escape_string($keywords) . "','" . count($results_object_array) . "','" . time() . "')",$xpert_site);
		
	if(count($results_object_array)==0){
	
		echo "<p>Sorry no search results found</p>";
			
	
	}else{
	
		if(isset($_GET['end'])){
			
			$end = $_GET['end'];
			$start = $_GET['start'];
		
		}else{
		
			$end = 20;
			$start = 0;
		
		}
			
		if($end>=count($results_object_array)){
		
			$end = count($results_object_array);
		
		}else{
		
			$end = $end;
		
		}
		
		$page_size = $end - $start;
		
		$pages = (int)count($results_object_array) / 20;
		
		echo "Pages ";
		
		$start_get = $start;
		
		$request = str_replace("/xpert/","",$_SERVER['REQUEST_URI']);
		
		if(strpos($request,"&start")==false){
		
			$request = substr($request,1);
		
		}else{
		
			$request = substr($request,1,strpos($request,"&start")-1);
		
		}
							
		for($q=0;$q<=$pages;$q++){
	
			if($_GET['end']==(($q+1)*20)){
	
				echo "<span>" . ($q+1)  . "  </span>";
		
			}else{
			
				echo "<span><a href=\"" . $request . "&start=" . $q*20 .  "&end=" . ($q+1)*20 . "\">" . ($q+1) . "</a>  </span>";
		
			}
	
		}
			
		echo "</div></div>";
		
		/////////////////////////////////
			
		echo "<div style=\"width:900px; text-align:left; margin:0 auto; clear:left; padding-left:20px;\">";
		
		asort($results_score_array,SORT_NUMERIC);
	
		$score_keys = array_keys($results_score_array);
	
	    for($y=$start;$y<$end;$y++){
	
			$index=$score_keys[(count($score_keys)-1)-$y];
	
			$query = "select * from xpert_core_scratch where resource_id = " . $index;
		
			$response = xpert_database_select_query($query,$xpert_site);
		
			$query = "select * from xpert_core_description where resource_id = " . $index;
		
			$response_desc = xpert_database_select_query($query,$xpert_site);
	
			echo "<p style=\"text-align:left\"><a style=\"color:#2E1D8F\" target=\"new\" href=\"" . $response->resource_link . "\">" . $response->resource_title . "</a><Br><span style=\"font-size:80%; color:#333\">  " . $response_desc->resource_description . "</span><br><span style=\"font-size:80%; font-weight:bold; color:#7A6A37;\">Author(s): </span><span style=\"font-size:80%;\">";
		
			$query = "select * from xpert_core_creator where resource_id = " . $index;
		
			$response = xpert_database_multiple_select_query($query,$xpert_site);
		
			while($author = xpert_database_fetch_object_from_response($response)){
		
				$author_string .= utf8_encode($author->resource_creator) . "; ";

			}
			
			echo substr($author_string,0,strlen($author_string)-2);
			
			$author_string="";
		
			echo "</span><br></p>";
		
			$query = "select * from xpert_core_rights where resource_id = " . $index;
		
			$response = xpert_database_select_query($query,$xpert_site);
		
			echo "<div id=\"button_bar_$index\" class=\"button_bar_index\">";
		
			echo "<div number=\"$index\" class=\"license\" onClick=\"toggle(this)\">License information</div>";
		
			echo "<div number=\"$index\" class=\"related\" onClick=\"toggle(this)\">Related content</div>";
				
			echo "<div number=\"$index\" class=\"recommend\" onClick=\"toggle(this)\">Recommend</div></div>";
		
			echo "<div class=\"tab_holder\"><p id=\"license_$index\" style=\"border-top:1px solid #655723; margin:10px; padding:10px;\">" . utf8_encode($response->resource_rights) . "</p>";
		
			$query = "select * from xpert_core_relation where resource_id = " . $index;
		
			$response_relation = xpert_database_multiple_select_query($query,$xpert_site);
			
			echo "<p id=\"relation_$index\" class=\"relation\">";
			
			while($relation = xpert_database_fetch_object_from_response($response_relation)){
		
				echo utf8_encode($relation->resource_relation) . "<br> ";

			}
			
			echo "</p>";
		
			echo "<p id=\"reco_$index\" class=\"recommender\"><form number=\"$index\" id=\"form_$index\" action=\"javascript:mail_send($index)\" style=\"margin:0px; padding:0px; display:none\">Your name<input style=\"margin:0 5px\" type=\"text\" size=\"20\" id=\"name_$index\" />Email address to send to<input style=\"margin-left:5px\" id=\"email_$index\" type=\"text\" size=\"40\" /><input type=\"image\" src=\"images/send.gif\" name=\"email_$index\" style=\"vertical-align:middle; margin-left:5px;\"/></form></p></div>";

		}
		
		?>

			<div style="width:900px; text-align:left; margin:0 auto; clear:left; color:#665723; font-weight:bold; height:20px; padding-top:10px; margin-bottom:25px;">
				<div style="float:right; font-size:80%; color:#333;"> Pages

		<?
	
		$request = str_replace("/xpert/","",$_SERVER['REQUEST_URI']);
		
		if(strpos($request,"&start")==false){
		
			$request = substr($request,1);
		
		}else{
		
			$request = substr($request,1,strpos($request,"&start")-1);
		
		}
							
		for($q=0;$q<=$pages;$q++){
	
			if($_GET['end']==(($q+1)*20)){
	
				echo "<span style=\"color:#665723;\">" . ($q+1)  . "  </span>";
		
			}else{
			
				echo "<span><a style=\"color:#665723;\" href=\"" . $request . "&start=" . $q*20 .  "&end=" . ($q+1)*20 . "\">" . ($q+1) . "</a>  </span>";
		
			}
	
		}
		
		echo "</div></div>";
		
	}
	
?>

<div style="width:900px; text-align:left; margin:0 auto; height:100px;">
			<div class="logo">
				<img src="http://www.nottingham.ac.uk/xpert/images/logoresults.gif" />
			</div>
			<div class="top_search_box">
				<form action="scoreresults.php" method="get" enctype="multipart/form-data">
					<input type="text" size="70" name="keywords" value='<? echo stripcslashes($_GET['keywords']); ?>' />
					<input type="image" src="http://www.nottingham.ac.uk/xpert/images/search.gif" style="position:relative; top:15px" />
				</form>
				<p>
					<a href="advancedsearch.php">Advanced search</a> | <a href="browse.php">Browse Resources</a>
				</p>	
			</div>
		</div>
	<div style="width:100%; background-color:#FFF; clear:both; float:left; text-align:center; color:#8E8E8E; font-size:75%">
		Copyright 2009 University of Nottingham
	</div>
</div>
<!-- Start - Webtrends tagging -->
<script type="text/javascript"
src="http://www.nottingham.ac.uk/common/webtrends/sdc-advanced-tracking.
js"></script>
<script type="text/javascript">
//<![CDATA[
	var gDomain = "uiwwwwbt01.ad.nottingham.ac.uk";
	var gDcsId  = "dcsuhohgd10000oiqfkmqufiu_6c8f"; // ]]> </script> <script type="text/javascript"
src="http://www.nottingham.ac.uk/common/webtrends/sdc.js"></script>
<noscript><img alt="" border="0" name="dcsimg" width="1" height="1"
src="http://uiwwwwbt01.ad.nottingham.ac.uk/dcsuhohgd10000oiqfkmqufiu_6c8
f/njs.gif?dcsuri=/nojavascript&amp;WT.js=No&amp;WT.tv=8.0.0"
/></noscript>
<!-- End - Webtrends tagging -->

</body>
</html>
